package com.muse.disruptor1;

import com.lmax.disruptor.RingBuffer;

public class OrderProducer {

    private RingBuffer<OrderEvent> ringBuffer;

    public OrderProducer(RingBuffer<OrderEvent> ringBuffer){
        this.ringBuffer = ringBuffer;
    }

    public void sendData(String uuid){
        long sequence = ringBuffer.next();
        try {
            OrderEvent orderEvent = ringBuffer.get(sequence);
            orderEvent.setId(uuid);
        } finally {
            ringBuffer.publish(sequence);
        }
    }
}
